<?php

namespace App\Eloquent;

class Navigation extends Model
{
    protected $fillable = ['name','link','description','sort','parent_id'];

    /**
     * 根据排除该id 查询父级导航
     *
     * @param int $id
     * @return array
     */
    public static function getParents(int $id = -1 )
    {
        return Navigation::where('id', '!=', $id)
            ->where('parent_id', '!=', $id)
            ->lists('name', 'id');
    }

    /*
     *获取导航
     */
    public static function getNavigation(){
        return Navigation::orderBy('sort','asc')
            ->get();
    }

}